import React from 'react';
// 导入路由组件
import { lazy, Suspense } from 'react'
import { Route, Redirect, Switch } from 'react-router-dom';
import Loading from '@/components/Loading';
const Home = lazy(() => import('@/views/Home'))
const Car = lazy(() => import('@/views/Car'))
const Mine = lazy(() => import('@/views/Mine'))
const Login = lazy(() => import('@/views/Login'))
const Detail = lazy(() => import('@/views/Detail'))
const Regist = lazy(() => import('@/views/Regist'))
const Index = () => {
    return (
        <>
            <Suspense fallback={<Loading></Loading>}>
                <Switch>
                    <Route path='/home' component={Home}></Route>
                    <Route path='/car' component={Car}></Route>
                    <Route path='/mine' component={Mine}></Route>
                    <Route path='/login' component={Login}></Route>
                    <Route path='/detail/:id' component={Detail}></Route>
                    <Route path='/regist' component={Regist}></Route>
                    <Redirect from='/' to='/home' exact></Redirect>
                </Switch>
            </Suspense>
        </>
    );
}

export default Index;
